<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Template
 *
 * @author wlf
 */
if(!defined('TinyFW')) exit('Access denied!');

class tfTemplate {
    //put your code here
    private static $instance = null;
    private $tpl = null;
    private $tpl_name = 'Smarty';

    public function __clone() {}

    public static function singleton() {
        if(!isset(self::$instance)) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    private function __construct() {
        //construct template engine
        if(tfConfig::getConfig('tpl_engine') <> '' ) {
            $this->tpl_name = tfConfig::getConfig("tpl_engine");
        }
       
        //載入文件
        include_once(SYS_PATH . "libs" . DS . "tf" . $this->tpl_name.".class.php");
        $tplname = "tf".$this->tpl_name;
        $this->tpl = new $tplname();
        
    }

    private function _get_tpl_name() {
        return $this->tpl_name;
    }
    private function _get_tpl() {
        return $this->tpl;
    }

    public static function getTplName() {
        return self::singleton()->_get_tpl_name();
    }

    public static function getTpl(){
        return self::singleton()->_get_tpl();
    }

    public static function __callStatic($method_name, $params){
        //echo "method=". $method_name."<br>";
        //echo "arguments=";
        //print_r($params);

        return call_user_method_array($method_name, self::singleton()->_get_tpl(), $params);
        
    }


}
?>
